function RedPacket(params){ 
	 
}

RedPacket.Where = function(type,proxy){
	this.type = type;
	this.proxy=proxy;
	this.linked = null;
	this.set = null;
	if(this.type==0){
		this.set = new RedPacket.Where(1,true);
		this.set.linked = this;
	}
	this.getProxy = function(){
		var m = new RedPacket.Where(this.type);//当前的对像
		if(this.type==0){
			m.set = new RedPacket.Where(1,true);//set对象
			m.set.linked = m;
		}else{
			m.linked=this.linked;
			this.linked.linked=m;
		}
		return m;
	}
	this.data = {};
	this.put = function(key,value){
		this.data[key] = value;
	}
	this.get = function(key){
		return this.data[key];
	}
	/** 编号 [非空]       **/
	this.id=function(id){if(this.proxy)return this.getProxy().id(id);  this.put("id", id);return this;};
	/** and id is null */
	this.idNull=function(){if(this.proxy)return this.getProxy().idNull();if(this.get("idNot")==null)this.put("idNot", "");this.put("id", null);return this;};
	/** not .... */
	this.idNot=function(){if(this.proxy)return this.getProxy().idNot();this.put("idNot", "not");return this;};
	this.idNotNull=function(){if(this.proxy)return this.getProxy().idNotNull();this.put("idNot", "not");this.put("id", null);return this;};
	this.idNot=function(id){if(this.proxy)return this.getProxy().idNot(id);this.put("idNot", "not");this.put("id", id);return this;};
	/** and id <= ? */
	this.idMin=function(min){if(this.proxy)return this.getProxy().idMin(min);this.put("idMin", min);return this;};
	/** and id >= ? */
	this.idMax=function(max){if(this.proxy)return this.getProxy().idMax(max);this.put("idMax", max);return this;};
	this.idIn=function(ids){
		if(this.proxy)return this.getProxy().idIn(ids);  this.put("idIn", ids);return this;
	};	
	
	/** 品牌信息 [非空] [Merchant]      **/
	this.merchant=function(merchant){if(this.proxy)return this.getProxy().merchant(merchant);  this.put("merchant", merchant);return this;};
	/** and merchant is null */
	this.merchantNull=function(){if(this.proxy)return this.getProxy().merchantNull();if(this.get("merchantNot")==null)this.put("merchantNot", "");this.put("merchant", null);return this;};
	/** not .... */
	this.merchantNot=function(){if(this.proxy)return this.getProxy().merchantNot();this.put("merchantNot", "not");return this;};
	this.merchantNotNull=function(){if(this.proxy)return this.getProxy().merchantNotNull();this.put("merchantNot", "not");this.put("merchant", null);return this;};
	this.merchantNot=function(merchant){if(this.proxy)return this.getProxy().merchantNot(merchant);this.put("merchantNot", "not");this.put("merchant", merchant);return this;};
	this.merchantIn=function(ids){
		if(this.proxy)return this.getProxy().merchantIn(ids);  this.put("merchantIn", ids);return this;
	};	
	
	/** 用户编号 [非空]       **/
	this.uid=function(uid){if(this.proxy)return this.getProxy().uid(uid);  this.put("uid", uid);return this;};
	/** and uid is null */
	this.uidNull=function(){if(this.proxy)return this.getProxy().uidNull();if(this.get("uidNot")==null)this.put("uidNot", "");this.put("uid", null);return this;};
	/** not .... */
	this.uidNot=function(){if(this.proxy)return this.getProxy().uidNot();this.put("uidNot", "not");return this;};
	this.uidNotNull=function(){if(this.proxy)return this.getProxy().uidNotNull();this.put("uidNot", "not");this.put("uid", null);return this;};
	this.uidNot=function(uid){if(this.proxy)return this.getProxy().uidNot(uid);this.put("uidNot", "not");this.put("uid", uid);return this;};
	/** and uid <= ? */
	this.uidMin=function(min){if(this.proxy)return this.getProxy().uidMin(min);this.put("uidMin", min);return this;};
	/** and uid >= ? */
	this.uidMax=function(max){if(this.proxy)return this.getProxy().uidMax(max);this.put("uidMax", max);return this;};
	this.uidIn=function(ids){
		if(this.proxy)return this.getProxy().uidIn(ids);  this.put("uidIn", ids);return this;
	};	
	
	/** 发红包人 [非空] [Member]      **/
	this.redEnveloper=function(redEnveloper){if(this.proxy)return this.getProxy().redEnveloper(redEnveloper);  this.put("redEnveloper", redEnveloper);return this;};
	/** and red_enveloper is null */
	this.redEnveloperNull=function(){if(this.proxy)return this.getProxy().redEnveloperNull();if(this.get("redEnveloperNot")==null)this.put("redEnveloperNot", "");this.put("redEnveloper", null);return this;};
	/** not .... */
	this.redEnveloperNot=function(){if(this.proxy)return this.getProxy().redEnveloperNot();this.put("redEnveloperNot", "not");return this;};
	this.redEnveloperNotNull=function(){if(this.proxy)return this.getProxy().redEnveloperNotNull();this.put("redEnveloperNot", "not");this.put("redEnveloper", null);return this;};
	this.redEnveloperNot=function(redEnveloper){if(this.proxy)return this.getProxy().redEnveloperNot(redEnveloper);this.put("redEnveloperNot", "not");this.put("redEnveloper", redEnveloper);return this;};
	this.redEnveloperIn=function(ids){
		if(this.proxy)return this.getProxy().redEnveloperIn(ids);  this.put("redEnveloperIn", ids);return this;
	};	
	
	/** 红包数量 [非空]       **/
	this.quantity=function(quantity){if(this.proxy)return this.getProxy().quantity(quantity);  this.put("quantity", quantity);return this;};
	/** and quantity is null */
	this.quantityNull=function(){if(this.proxy)return this.getProxy().quantityNull();if(this.get("quantityNot")==null)this.put("quantityNot", "");this.put("quantity", null);return this;};
	/** not .... */
	this.quantityNot=function(){if(this.proxy)return this.getProxy().quantityNot();this.put("quantityNot", "not");return this;};
	this.quantityNotNull=function(){if(this.proxy)return this.getProxy().quantityNotNull();this.put("quantityNot", "not");this.put("quantity", null);return this;};
	this.quantityNot=function(quantity){if(this.proxy)return this.getProxy().quantityNot(quantity);this.put("quantityNot", "not");this.put("quantity", quantity);return this;};
	/** and quantity <= ? */
	this.quantityMin=function(min){if(this.proxy)return this.getProxy().quantityMin(min);this.put("quantityMin", min);return this;};
	/** and quantity >= ? */
	this.quantityMax=function(max){if(this.proxy)return this.getProxy().quantityMax(max);this.put("quantityMax", max);return this;};
	this.quantityIn=function(ids){
		if(this.proxy)return this.getProxy().quantityIn(ids);  this.put("quantityIn", ids);return this;
	};	
	
	/** 余额产品 [非空] [Product]      **/
	this.product=function(product){if(this.proxy)return this.getProxy().product(product);  this.put("product", product);return this;};
	/** and product is null */
	this.productNull=function(){if(this.proxy)return this.getProxy().productNull();if(this.get("productNot")==null)this.put("productNot", "");this.put("product", null);return this;};
	/** not .... */
	this.productNot=function(){if(this.proxy)return this.getProxy().productNot();this.put("productNot", "not");return this;};
	this.productNotNull=function(){if(this.proxy)return this.getProxy().productNotNull();this.put("productNot", "not");this.put("product", null);return this;};
	this.productNot=function(product){if(this.proxy)return this.getProxy().productNot(product);this.put("productNot", "not");this.put("product", product);return this;};
	this.productIn=function(ids){
		if(this.proxy)return this.getProxy().productIn(ids);  this.put("productIn", ids);return this;
	};	
	
	/** 红包类型 [非空]   1:单人红包 2:多人红包     **/
	this.types=function(types){if(this.proxy)return this.getProxy().types(types);  this.put("types", types);return this;};
	/** and types is null */
	this.typesNull=function(){if(this.proxy)return this.getProxy().typesNull();if(this.get("typesNot")==null)this.put("typesNot", "");this.put("types", null);return this;};
	/** not .... */
	this.typesNot=function(){if(this.proxy)return this.getProxy().typesNot();this.put("typesNot", "not");return this;};
	this.typesNotNull=function(){if(this.proxy)return this.getProxy().typesNotNull();this.put("typesNot", "not");this.put("types", null);return this;};
	this.typesNot=function(types){if(this.proxy)return this.getProxy().typesNot(types);this.put("typesNot", "not");this.put("types", types);return this;};
	this.typesIn=function(ids){
		if(this.proxy)return this.getProxy().typesIn(ids);  this.put("typesIn", ids);return this;
	};	
	
	/** 默认有效期 [非空]       **/
	this.validity=function(validity){if(this.proxy)return this.getProxy().validity(validity);  this.put("validity", validity);return this;};
	/** and validity is null */
	this.validityNull=function(){if(this.proxy)return this.getProxy().validityNull();if(this.get("validityNot")==null)this.put("validityNot", "");this.put("validity", null);return this;};
	/** not .... */
	this.validityNot=function(){if(this.proxy)return this.getProxy().validityNot();this.put("validityNot", "not");return this;};
	this.validityNotNull=function(){if(this.proxy)return this.getProxy().validityNotNull();this.put("validityNot", "not");this.put("validity", null);return this;};
	this.validityNot=function(validity){if(this.proxy)return this.getProxy().validityNot(validity);this.put("validityNot", "not");this.put("validity", validity);return this;};
	/** and validity >= ? */
	this.validityStart=function(start){if(this.proxy)return this.getProxy().validityStart(start);this.put("validityStart", start);return this;};			
	/** and validity <= ? */
	this.validityEnd=function(end){if(this.proxy)return this.getProxy().validityEnd(end);this.put("validityEnd", end);return this;};
	
	/** 已领取人数        **/
	this.recipients=function(recipients){if(this.proxy)return this.getProxy().recipients(recipients);  this.put("recipients", recipients);return this;};
	/** and recipients is null */
	this.recipientsNull=function(){if(this.proxy)return this.getProxy().recipientsNull();if(this.get("recipientsNot")==null)this.put("recipientsNot", "");this.put("recipients", null);return this;};
	/** not .... */
	this.recipientsNot=function(){if(this.proxy)return this.getProxy().recipientsNot();this.put("recipientsNot", "not");return this;};
	this.recipientsNotNull=function(){if(this.proxy)return this.getProxy().recipientsNotNull();this.put("recipientsNot", "not");this.put("recipients", null);return this;};
	this.recipientsNot=function(recipients){if(this.proxy)return this.getProxy().recipientsNot(recipients);this.put("recipientsNot", "not");this.put("recipients", recipients);return this;};
	/** and recipients <= ? */
	this.recipientsMin=function(min){if(this.proxy)return this.getProxy().recipientsMin(min);this.put("recipientsMin", min);return this;};
	/** and recipients >= ? */
	this.recipientsMax=function(max){if(this.proxy)return this.getProxy().recipientsMax(max);this.put("recipientsMax", max);return this;};
	this.recipientsIn=function(ids){
		if(this.proxy)return this.getProxy().recipientsIn(ids);  this.put("recipientsIn", ids);return this;
	};	
	
	/** 唯一标识        **/
	this.unique=function(unique){if(this.proxy)return this.getProxy().unique(unique);  this.put("unique", unique);return this;};
	/** and unique is null */
	this.uniqueNull=function(){if(this.proxy)return this.getProxy().uniqueNull();if(this.get("uniqueNot")==null)this.put("uniqueNot", "");this.put("unique", null);return this;};
	/** not .... */
	this.uniqueNot=function(){if(this.proxy)return this.getProxy().uniqueNot();this.put("uniqueNot", "not");return this;};
	this.uniqueNotNull=function(){if(this.proxy)return this.getProxy().uniqueNotNull();this.put("uniqueNot", "not");this.put("unique", null);return this;};
	this.uniqueNot=function(unique){if(this.proxy)return this.getProxy().uniqueNot(unique);this.put("uniqueNot", "not");this.put("unique", unique);return this;};
	
	/** 修改时间 [非空]       **/
	this.updateTime=function(updateTime){if(this.proxy)return this.getProxy().updateTime(updateTime);  this.put("updateTime", updateTime);return this;};
	/** and update_time is null */
	this.updateTimeNull=function(){if(this.proxy)return this.getProxy().updateTimeNull();if(this.get("updateTimeNot")==null)this.put("updateTimeNot", "");this.put("updateTime", null);return this;};
	/** not .... */
	this.updateTimeNot=function(){if(this.proxy)return this.getProxy().updateTimeNot();this.put("updateTimeNot", "not");return this;};
	this.updateTimeNotNull=function(){if(this.proxy)return this.getProxy().updateTimeNotNull();this.put("updateTimeNot", "not");this.put("updateTime", null);return this;};
	this.updateTimeNot=function(updateTime){if(this.proxy)return this.getProxy().updateTimeNot(updateTime);this.put("updateTimeNot", "not");this.put("updateTime", updateTime);return this;};
	/** and update_time >= ? */
	this.updateTimeStart=function(start){if(this.proxy)return this.getProxy().updateTimeStart(start);this.put("updateTimeStart", start);return this;};			
	/** and update_time <= ? */
	this.updateTimeEnd=function(end){if(this.proxy)return this.getProxy().updateTimeEnd(end);this.put("updateTimeEnd", end);return this;};
	
	/** 发放时间 [非空]       **/
	this.addTime=function(addTime){if(this.proxy)return this.getProxy().addTime(addTime);  this.put("addTime", addTime);return this;};
	/** and add_time is null */
	this.addTimeNull=function(){if(this.proxy)return this.getProxy().addTimeNull();if(this.get("addTimeNot")==null)this.put("addTimeNot", "");this.put("addTime", null);return this;};
	/** not .... */
	this.addTimeNot=function(){if(this.proxy)return this.getProxy().addTimeNot();this.put("addTimeNot", "not");return this;};
	this.addTimeNotNull=function(){if(this.proxy)return this.getProxy().addTimeNotNull();this.put("addTimeNot", "not");this.put("addTime", null);return this;};
	this.addTimeNot=function(addTime){if(this.proxy)return this.getProxy().addTimeNot(addTime);this.put("addTimeNot", "not");this.put("addTime", addTime);return this;};
	/** and add_time >= ? */
	this.addTimeStart=function(start){if(this.proxy)return this.getProxy().addTimeStart(start);this.put("addTimeStart", start);return this;};			
	/** and add_time <= ? */
	this.addTimeEnd=function(end){if(this.proxy)return this.getProxy().addTimeEnd(end);this.put("addTimeEnd", end);return this;};
	
	/** 状态 [非空]   1:有效中 0:已失效     **/
	this.status=function(status){if(this.proxy)return this.getProxy().status(status);  this.put("status", status);return this;};
	/** and status is null */
	this.statusNull=function(){if(this.proxy)return this.getProxy().statusNull();if(this.get("statusNot")==null)this.put("statusNot", "");this.put("status", null);return this;};
	/** not .... */
	this.statusNot=function(){if(this.proxy)return this.getProxy().statusNot();this.put("statusNot", "not");return this;};
	this.statusNotNull=function(){if(this.proxy)return this.getProxy().statusNotNull();this.put("statusNot", "not");this.put("status", null);return this;};
	this.statusNot=function(status){if(this.proxy)return this.getProxy().statusNot(status);this.put("statusNot", "not");this.put("status", status);return this;};
	this.statusIn=function(ids){
		if(this.proxy)return this.getProxy().statusIn(ids);  this.put("statusIn", ids);return this;
	};	
	
	
	
	this.add=function(key,value) {if(proxy)return proxy().add(key,value);this.put(key, value);return this;}
	this.desc=function(sql) {if(proxy)return proxy().desc(sql);this.put("desc", sql);return this;}
	this.asc=function(sql) {if(proxy)return proxy().asc(sql);this.put("asc", sql);return this;}
	this.definex=function(sql) {if(proxy)return proxy().definex(sql);this.put("definex", sql);return this;}
	
	/** 获取所有派发红包 **/
	this.list=function(size){
		this.data.size = size;
		var protocol = ux.ajax("/admin/products/redpacket.list.do",this.data);
		if(!protocol)return null;
		if(protocol.data && protocol.data.list)return protocol.data.list;
		return [];
	}
	/** 获取派发红包分页 **/
	this.page=function(page,size){
		this.data.size = size;
		this.data.page = page;
		var protocol = ux.ajax("/admin/products/redpacket.list.do",this.data);
		if(!protocol)return null;
		if(protocol.data)return data;
		return {list:[]};
	}
	/** 根据查询条件取派发红包 **/
	this.get=function(){
		this.data.size = 1;
		var protocol = ux.ajax("/admin/products/redpacket.list.do",this.data);
		if(!protocol)return null;
		if(protocol.data && protocol.data.list && protocol.data.list.length==1)return protocol.data.list[0]; 
		return null;
	}
}

RedPacket.get = function(id){
	var protocol = ux.ajax("/admin/products/redpacket.get.do",{id:id});
	if(!protocol)return null;
	if(protocol.data)return protocol.data.redPacket;
	return null;
}

RedPacket.where = new RedPacket.Where(0,true);